EditIndustry = function() {
	return {
		saveIndustryInfo : function() {
			var channelId = $('#channelId').val();
			if(null == channelId || "" == channelId) {
				Ict.warn("请选择频道!");
				return;
			}
			if(!$('#industryForm').form('validate')) {
				return;
			}
			var industryId = $("#industryId").val();
			var industryName = $.trim($("#industryName").val());
			$.post('/pc/industry/check.htm', {'industryName' : industryName, 'industryId' : industryId}, function(data) {
				if(data.code == '0') {
					Ict.warn("行业名称已存在,请重新输入!");
				} else {
					EditIndustry.commitForm();
				}
			});
		},
		
		commitForm : function() {
			$("select[name='channelId']").attr("disabled", false);
			$("input[name='industryName']").attr("disabled", false);
			$('#industryForm').form('submit', {
				url      : "/pc/industry/saveIndustry.htm",
				onSubmit : function() {
					return $('#industryForm').form('validate');
				},
				success  : function(data) {
					if(data == "SUCCESS") {
						Ict.info("保存成功!", function() {
			    			Ict.closeWin();
			    			$("#industryDataGrid").datagrid("reload");
			    		});
					} else {
						Ict.info("保存失败!");
					}
				}
			});
		}
	};
}();

$(function(){
	$("select[name='channelId']").attr("disabled", true);
	$("input[name='industryName']").attr("disabled", true);
	
	$("#industryLife").numberbox({
		min       : 0,
		precision : 2,
		required  : true
	});
});